#include "xNetService.h"

namespace xNet
{
    xNetService::xNetService(std::string strIp,uint16 wPort)
                : xService{strIp,wPort}
                , m_accepter{strIp,wPort}
    {
    }

    bool xNetService::Init()
    {   
        return m_accepter.Init();
    }

    void xNetService::Finish()
    {   
        xService::Finish();
        m_accepter.Finish();
    }

    bool xNetService::ServiceCallBack()
    {
        int ret = m_accepter.Accept();
        for(int i=0;i<ret;i++)
        {
            xSocket* sock = nullptr;
            while((sock = m_accepter.GetServiceSock().Accept()) != nullptr)
            {
                NewTCPTask(sock);
            }
        }
        return true;
    }
}